package com.taro.jpushplugin;


import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.util.Log;

public class TaroApp extends Application {



    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("TARO", "run onCreate");
        String processName = getCurProcessName(getApplicationContext());
        if (getApplicationInfo().packageName.equals(processName)) {
            //在主线程里面才能确保，所有的类都已经加载过
            // 现在只有mini线程，如果以后再有其他的服务开启了新的线程，需要测试处理

        }
        Log.i("TARO", "End App onCreate");
    }



    /**
     * 获得当前进程的名字
     *
     * @param context
     * @return 进程号
     */
    private static String getCurProcessName(Context context) {

        int pid = android.os.Process.myPid();

        ActivityManager activityManager = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);

        for (ActivityManager.RunningAppProcessInfo appProcess : activityManager
                .getRunningAppProcesses()) {

            if (appProcess.pid == pid) {
                return appProcess.processName;
            }
        }
        return null;
    }

}